class_name Level extends Node2D

@onready var player_spawn_positions: Node2D = $PlayerSpawnPositions
@onready var level_end_timer: Timer = $LevelEndTimer

@export var level_index: int = 0

func _ready() -> void:
	var positions: Array[Vector2] = []
	for i in player_spawn_positions.get_children():
		positions.append(i.global_position)
	Game.multiplayer_spawn.spawn_players(positions)
	
	SignalManager.player_update.emit()


func _on_enemy_spawner_enemy_clear() -> void:
	level_end_timer.start()


func _on_level_end_timer_timeout() -> void:
	Game.set_state.rpc(Game.GameState.GAMING, Game.current_level + 1)
